cmake_minimum_required(VERSION 3.5)
project(vaapi_decode)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(hb_msgs REQUIRED)

link_directories("/usr/local/lib")
link_directories("/usr/lib/x86_64-linux-gnu")
include_directories(include)
include_directories("/usr/local/include")

find_library(libavformat libavformat.a REQUIRED)
find_library(libavcodec libavcodec.a REQUIRED)
find_library(libavdevice libavdevice.a REQUIRED)
find_library(libavutil libavutil.a REQUIRED)
find_library(libswscale libswscale.a REQUIRED)
find_library(libavfilter libavfilter.a REQUIRED)
find_library(libswresample libswresample.a REQUIRED)
find_library(libz libz.a REQUIRED)
find_library(libpthread libpthread.so REQUIRED)
find_library(liblzma liblzma.a REQUIRED)
find_library(libva libva.so REQUIRED)
find_library(libvadrm libva-drm.so REQUIRED)
find_library(libvax11 libva-x11.so REQUIRED)
find_library(libX11 libX11.so REQUIRED)

add_executable(decoder src/vaapi_decoder.cpp src/decoder_node.cpp)
ament_target_dependencies(decoder rclcpp sensor_msgs hb_msgs)

target_link_libraries(
	decoder
    libavfilter.a
	libavformat.a
    libavcodec.a
    libavutil.a
    libswresample.a
	libswscale.a
    libavdevice.a
	libpthread.so
	libz.a
	liblzma.a
	libva.so
	libva-drm.so
	libva-x11.so
	libX11.so
)

install(
	TARGETS decoder
	DESTINATION lib/${PROJECT_NAME}
)

install(
	DIRECTORY launch
	DESTINATION share/${PROJECT_NAME}
)


ament_package()
